//
//  JSONDataConvertiable.swift
//  JLDiaryApp
//
//  Created by Jiang Chencheng on 2024/9/28.
//

import Foundation

protocol JSONDataConvertiable: DataConvertible, Codable {}

extension JSONDataConvertiable {
    init(data: Data) throws {
        let object: Self = try JSONCoder.decode(data: data)
        self = object
    }

    func toData() throws -> Data {
        let data = try JSONCoder.encode(object: self)
        return data
    }
}
